package com.younion.business.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.younion.business.IWebFileService;
import com.younion.common.exception.BaseException;
import com.younion.common.paginator.Paginator;
import com.younion.dao.WebFileDAO;
import com.younion.vo.WebFileVO;

import cpcns.jhsks.util.MapCollectionUtils;

public class WebFileServiceImpl extends BaseService implements IWebFileService {

	protected static final Log logger = LogFactory
			.getLog(WebFileServiceImpl.class);

	private WebFileDAO webFileDAO;

	public boolean deleteWebFileById(int id) throws BaseException {
		try {
			return this.webFileDAO.deleteWebFileById(id);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public boolean deleteWebFileById(int id) error occur:",
					e);
		}
	}

	public boolean deleteWebFileByIds(List list) throws BaseException {
		try {
			return this.webFileDAO.deleteWebFileByIds(list);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public boolean deleteWebFileByIds(List list) error occur:",
					e);
		}
	}

	public Integer insertByVo(WebFileVO webFileVO) throws BaseException {
		try {
			return this.webFileDAO.insertByVo(webFileVO);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public Integer insertByVo(WebFileVO webFileVO) error occur:",
					e);
		}
	}

	public WebFileVO selectWebFileById(int id) throws BaseException {
		try {
			return this.webFileDAO.selectWebFileById(id);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public WebFileVO selectWebFileById(int id) error occur:",
					e);
		}
	}

	public List<WebFileVO> selectByIds(List list) throws BaseException {
		try {
			return this.webFileDAO.selectByIds(list);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public List<WebFileVO> selectByIds(List list) error occur:",
					e);
		}
	}

	public int selectCountByMap(Map paramMap) throws BaseException {
		try {
			return this.webFileDAO.selectCountByMap(paramMap);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public List<WebFileVO> selectByIds(List list) error occur:",
					e);
		}
	}

	public List selectForPage(Map condition, Paginator paginator)
			throws BaseException {
		if (MapCollectionUtils.isEmpty(condition))
			return null;
		try {
			Map map = new HashMap();
			map.put("paramMap", condition);
			return this.webFileDAO.selectForPage(map, paginator);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public List selectForPage(Map condition, Paginator paginator) error occur:",
					e);
		}
	}

	public int selectMaxTop() throws BaseException {
		try {
			return this.webFileDAO.selectMaxTop();
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(WebFileServiceImpl.class.getName()
					+ " >> public int selectMaxTop() error occur:", e);
		}
	}

	public boolean updateWebFileByMap(Map paramMap) throws BaseException {
		try {
			return this.webFileDAO.updateWebFileByMap(paramMap);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					WebFileServiceImpl.class.getName()
							+ " >> public boolean updateWebFileByMap(Map paramMap) error occur:",
					e);
		}
	}

	public void updateTopById(Map map) throws BaseException {
		try {
			this.webFileDAO.updateTopById(map);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(WebFileServiceImpl.class.getName()
					+ " >> public void updateTopById(Map map) error occur:", e);
		}
	}

	public WebFileDAO getWebFileDAO() {
		return webFileDAO;
	}

	public void setWebFileDAO(WebFileDAO webFileDAO) {
		this.webFileDAO = webFileDAO;
	}

}